/*
ID: majowi1
LANG: JAVA
PROG: ride
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

final class ride {
	static char[] letters = new char[] { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	
	public static void main(String[] args) throws IOException {
		//System.err.println("test1 ok") ;
	    BufferedReader f = new BufferedReader(new FileReader("ride.in"));	    
	    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("ride.out")));
	    	    
	    if (getTheNumber(f.readLine().trim()) == getTheNumber(f.readLine().trim()))
	    	out.println("GO");
	    else
	    	out.println("STAY");	    
	    out.close();                                
	    System.exit(0);
	}
	
	private static int getTheNumber(String in){
		int result = 1;
	    char[] temp = in.toCharArray();
	    
	    for (char a : temp)
	    {	    
	    	for (int x=0; x<letters.length; x++)
	    	{
	    		if (letters[x] == a){	    			
	    			result = result * (x+1);	    			
	    			break;
	    		}
	    	}
	    }	    
	 return result % 47;
	}
}
